﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace MRS.WebUI
{
    public partial class Logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[MRSUtil.MRSConsts.MRS_User_Session] != null)
            {
                MRS.DBL.Model.User userModel = Session[MRSUtil.MRSConsts.MRS_User_Session] as MRS.DBL.Model.User;
                Response.Cookies[MRSUtil.MRSConsts.MRS_User_Cookie].Expires = DateTime.Now.AddDays(-1);
                FormsAuthentication.SignOut();
                ActiveUserHandler.Instance().RemoveUser(userModel.Id);//退出活跃用户列表
                Session.Remove(MRSUtil.MRSConsts.MRS_User_Session);
                Session.Abandon();
                Response.Redirect("~/Index.aspx");
            }
        }
    }
}